import { defineStore } from "pinia";

export const useMemberInfoStore = defineStore('memberInfo',{
  state:()=>({
    memberInfo:{//会员信息
      name:'小明',
      age:'2-4岁',
      phone:'135-6666-6666',
      sex:'男孩'
    },
    pointOrderInfo:[//积分订单
      {
        orderId:'202008062202165901',
        orderStatus:'交易成功',
        imgSrc:'https://cdn3.axureshop.com/demo/2027306/images/%E7%A7%AF%E5%88%86%E8%AE%A2%E5%8D%95/u12894.svg',
        orderName:'礼物名称1',
        point:999
      },
      {
        orderId:'202108062202165901',
        orderStatus:'交易成功',
        imgSrc:'https://cdn3.axureshop.com/demo/2027306/images/%E7%A7%AF%E5%88%86%E8%AE%A2%E5%8D%95/u12894.svg',
        orderName:'礼物名称2',
        point:999
      },
      {
        orderId:'202208062202165901',
        orderStatus:'交易成功',
        imgSrc:'https://cdn3.axureshop.com/demo/2027306/images/%E7%A7%AF%E5%88%86%E8%AE%A2%E5%8D%95/u12894.svg',
        orderName:'礼物名称3',
        point:999
      }
    ],
    snInfo:[//sn码
      {
        id:'001',
        equipmentId:'XM784231895163',
        caeatTime:'2018-03-10 15:12:48'
      },
      {
        id:'002',
        equipmentId:'XM6666666666',
        caeatTime:'2018-03-10 15:12:48'
      }
    ]
  }),
  getters:{
    snInfoLength(){
      return this.snInfo.length
    }
  },
  actions:{
    changeName(name:string){
      if(this.memberInfo.name === name) return
      this.memberInfo.name = name
    },
    changeAge(age:string){
      if(this.memberInfo.age === age) return
      this.memberInfo.age = age
    },
    changeSex(sex:string){
      if(this.memberInfo.sex === sex) return
      this.memberInfo.sex = sex
    },
    addSnMa(obj){//添加sn码
      this.snInfo.push(obj)
    }
  }
})